﻿using App.IRepository;
using App.Model;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace App.Repository
{
    public class PhotoRepository : BaseRepository<Photo>, IPhotoRepository
    {
        public async override Task<List<Photo>> QueryAsync()
        {
            return await base.Context.Queryable<Photo>()
                .ToListAsync();
        }
        public async override Task<List<Photo>> QueryAsync(Expression<Func<Photo, bool>> func)
        {
            return await base.Context.Queryable<Photo>()
                .Where(func)
                 .ToListAsync();
        }
        public async override Task<List<Photo>> QueryAsync(int pageIndex, int pageSize, RefAsync<int> total)
        {
            return await base.Context.Queryable<Photo>()
                .ToPageListAsync(pageIndex, pageSize, total);

        }

        public async override Task<List<Photo>> QueryAsync(Expression<Func<Photo, bool>> func, int pageindex, int pageSize, RefAsync<int> total)
        {
            return await base.Context.Queryable<Photo>()
                .Where(func)
                .ToPageListAsync(pageindex, pageSize, total);
        }
        public PhotoRepository(ISqlSugarClient context) : base(context)
        {
        }
    }
}
